<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>展示页面</title>
    <script>
		var ysApi;	//声明ysApi变量。
        var divHint;

		function init() {

		    divHint = document.getElementById("divHint");

			document.getElementById("btnAddFavorite").onclick = (e) => {
			    let userData = ysApi.userData;
                if (!userData) {
                    ysApi.login();
                } else {
                    divHint.innerText = "用户已经登录: " + JSON.stringify(userData) + " 调用分享功能！";
                }
            }
		}
    </script>
</head>
<body onload="init();">
	<input id="btnAddFavorite" type="button" value="添加收藏"/><br>
    <div id="divHint"></div>
</body>
</html>
